package cn.itamt.ui.base {
	import flash.display.Sprite;
	import flash.events.Event;	

	/**
	 * @author tamt
	 */
	public class TSprite extends Sprite {
		public function TSprite() {
			
			addEventListener(Event.ADDED_TO_STAGE, _onAdded);			addEventListener(Event.REMOVED_FROM_STAGE, _onRemoved);
		}

		private function _onAdded(evt : Event) : void {
			if(evt.target == this)onAdded();
		}

		private function _onRemoved(evt : Event) : void {
			if(evt.target == this)onRemoved();
		}
		
		protected function onAdded():void{
			
		}
		
		protected function onRemoved():void{
			
		}

		public function dispose() : void {
		}

		override public function dispatchEvent(evt : Event) : Boolean {
			if(hasEventListener(evt.type) || evt.bubbles) {
				return super.dispatchEvent(evt);
			}
			return true;
		}
	}
}
